# -*-coding:utf-8 -*-
from xgoutils import XGOController
import socket
localhost = "0.0.0.0"
port = 8090
server_sk = socket.socket()
server_sk.bind((localhost, port))
server_sk.listen(5)
print("等待程序链接……")
conn, address = server_sk.accept()

conn.sendall(bytes("连接成功！", encoding='utf-8'))
dog = XGOController("xgolite")

while True:
    ret = str(conn.recv(1024), encoding='utf-8')
    print("收到客户端信息是：", ret)
    if ret == 'q':
        break
    else:
        dog.go(str(ret))
        conn.sendall(bytes("执行完成", encoding='utf-8'))

server_sk.close()
